#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int n, m, a[3005], min = 300005,count;
	
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n-m+1; i++)
	{			
		count = 0;
		for (int j = i; j <= m + i - 1; j++)
		{
			count += a[j];
		}
		if (count < min)
			min = count;
	}
	//}
    cout << min;
    return 0;
}